<?php
  if (isset($_GET['id']))
  {
    include("./../includes/conf.inc");
    $id = mysql_connect($db_host,$db_usr,$db_pass) or die('Could not connect: ' . mysql_error());;
    mysql_select_db($db_name);
    $query = "SELECT * FROM $tbl_name WHERE id=$id";
    $res = mysql_query($query);
    $obj = mysql_fetch_object($res);
    
    
    if (isset($_POST['update']))
    {
      $s = $_POST['update'];
      $query = "UPDATE $tbl_name SET name=$s WHERE id=$id";
      
      if (mysql_query($query))
      {
        echo "File $id updated ! <br> <a href='#' onMouseClick='javascript:window.close()'>Close window</a>";
      }
      else
      {
        echo "Error: Can't update the file $id ! <br> <a href='#' onMouseClick='javascript:window.close()'>Close window</a>";
      }
    }
    else
    {
    echo "
          <form method='POST'>
          <table align='center'>
          <tr>
          <td><img src='images/gallery/thumbnails/".$obj->link."' border=0></td>
          </tr>
          <tr>
          <input type='text' value=$obj->name name='update'>
          </tr>
          </table>
          </form>
          ";
    }
  }
?>
